#include "stdafx.h"
#include <http_msg.h>

using namespace http;

class form_response : public http_response
{
public:
	form_response(casablanca::string_t fileName = casablanca::string_t(L"")) : http_response(http::status_codes::OK)
	{
		headers().add(L"Content-Type", L"text/html");
		headers().add(L"Title", L"Speak to me!");				

		casablanca::stringstream_t output;
		output << L"<!DOCTYPE HTML>";
		output << L"<html>";
		output << L"<body>";
		if (!fileName.empty())
		{
			output << L"<audio autoplay='true'><source src='" << fileName << "' type='audio/wav'/>Your browser does not support the audio tag.</audio>";	
		}
		output << L"<form enctype='application/x-www-form-urlencoded' action='/' method='post' >";
		output << L"<input name='text' type='text'></input>";
		output << L"<input type='submit'/>";
		output << L"</form>";
		output << L"</body>";
		output << L"</html>";

		set_body(output.str());
	}
};
